Skip to content

Feat comparisons and numbers#8

Open
PEXEL2002 wants to merge 3 commits intomainfrom
feat-comparisons-and-numbers
Open

Feat comparisons and numbers#8
PEXEL2002 wants to merge 3 commits intomainfrom
feat-comparisons-and-numbers

Conversation

@PEXEL2002
Copy link
Copy Markdown
Owner

Description

This PR introduces critical parser improvements requested by the instructor and resolves priority issues with stacked fractions.

1. Floating-Point Numbers (Dot & Comma)

  • Updated the NUMBER token in the Lexer to accept both dot (3.14) and comma (3,14) formats.
  • Added a conversion in the Visitor: every comma in a numeric value is automatically replaced with a dot in the resulting LaTeX output to maintain mathematical consistency.

2. Multi-Variable Functions

  • Implemented the argumentList rule, allowing functions with any number of arguments (e.g., f(x, y), g(a, b, c)).
  • Added a COMMA token as an argument separator.
  • Note: For multi-variable functions, it is recommended to use a space after the comma to avoid ambiguity with the Polish decimal format.

3. Fraction Priority Fix (//)

  • Refactored the hierarchy in the expression rule. Division (fractions) now has a higher priority than implicit multiplication.
  • Behavior Examples:
    • Input 1 // 2 x now correctly generates \frac{1}{2} x (previously x was pulled into the denominator).
    • Input 1 // {2x} (or with grouping) correctly generates \frac{1}{2x}.

4. Enhanced Comparison Operators

  • Implemented a robust set of comparison operators with support for multiple notations (ASCII, Unicode, and keywords):
    • Less than or equal: <= or
    • Greater than or equal: >= or
    • Not equal: !=, <>, or
    • Equality: =, ==, or the keyword rowne
    • Basic relations: < and >
  • Rule Logic: Implemented a specific logic where inequalities require both sides, while the equality operator (=) allows for an empty right-hand side (to support "step-by-step" math solving).

Test Cases

Input (Natural Math) LaTeX Output Notes
x rowne 5 x = 5 Keyword equality
a != b a \neq b LaTeX command mapping
2,5 + 3.5 2.5 + 3.5 Unified to dot format
f(a, b, c) f(a, b, c) Multi-variable support
1 // 2 x \frac{1}{2} x Correct priority
1 //{2x} \frac{1}{2x}

@PEXEL2002 PEXEL2002 requested a review from MANDRW March 27, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant